﻿using System;
using SCG = System.Collections.Generic;

using Nemerle.Assertions;
using Nemerle.Utility;

using GASS.OpenCL;
using GASS.OpenCL.OpenCLDriver;

namespace Nemerle.OpenCL {

    public sealed class Buffer : Memory {

        public this(context : Context, size : long, flags = CLMemFlags.ReadWrite) {
            this(context, size, null, flags)
        }

        public this(context : Context, size : long, host_ptr : object, flags = CLMemFlags.ReadWrite)
            requires size > 0
        {
            base(context, host_ptr, flags);
            this.size = size;
            Initialize();
        }

        size : long;

        protected override CreateHandle(host_ptr : IntPtr) : CLMem {
            CheckErrorTail(clCreateBuffer(Context.Id, Flags, size, host_ptr))
        }

    }

}